#!/bin/bash

############################################################################
#
# 远程执行该脚本，请在命令行中直接执行以下命令：
#
#   curl -sSL https://gitee.com/tay3223/biubiubiu/raw/master/centos7-install-openresty.sh | /bin/bash
#
#
############################################################################


mkdir -p /opt/websuite
mkdir -p /opt/config/openresty
yum install -y pcre-devel openssl-devel gcc curl postgresql-devel perl-Digest-MD5


git clone http://172.16.2.7/sre/openresty.git /opt/config/openresty


mkdir -p ~/bao
wget -P ~/bao/ http://172.18.20.130/d/tar/openresty-1.21.4.2.tar.gz
tar -zxvf ~/bao/openresty-1.21.4.2.tar.gz -C ~/bao/

cd ~/bao/openresty-1.21.4.2/ || exit

./configure --prefix=/opt/websuite/openresty \
            --with-luajit \
            --with-http_iconv_module \
            --with-http_postgres_module \
            --with-http_v2_module \
            --with-http_realip_module \
            --with-http_stub_status_module \
            --add-module=/opt/config/openresty/monitoring/nginx-module-vts-0.2.2/

make && make install


tee /etc/profile.d/openresty.sh <<\EOF
export PATH=$PATH:/opt/websuite/openresty/nginx/sbin
export PATH=$PATH:/opt/websuite/openresty/bin
EOF

source /etc/profile
